/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package edu.mse.camel.client.posterboard.posterboard.impl;

import edu.mse.camel.client.posterboard.posterboard.PBDiagram;
import edu.mse.camel.client.posterboard.posterboard.PosterboardPackage;

import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Point;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.swt.graphics.RGB;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>PB Diagram</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link edu.mse.camel.client.posterboard.posterboard.impl.PBDiagramImpl#getDelegate <em>Delegate</em>}</li>
 *   <li>{@link edu.mse.camel.client.posterboard.posterboard.impl.PBDiagramImpl#isVisible <em>Visible</em>}</li>
 *   <li>{@link edu.mse.camel.client.posterboard.posterboard.impl.PBDiagramImpl#getForegroundColor <em>Foreground Color</em>}</li>
 *   <li>{@link edu.mse.camel.client.posterboard.posterboard.impl.PBDiagramImpl#getBackgroundColor <em>Background Color</em>}</li>
 *   <li>{@link edu.mse.camel.client.posterboard.posterboard.impl.PBDiagramImpl#getBorderColor <em>Border Color</em>}</li>
 *   <li>{@link edu.mse.camel.client.posterboard.posterboard.impl.PBDiagramImpl#getLineThickness <em>Line Thickness</em>}</li>
 *   <li>{@link edu.mse.camel.client.posterboard.posterboard.impl.PBDiagramImpl#getSize <em>Size</em>}</li>
 *   <li>{@link edu.mse.camel.client.posterboard.posterboard.impl.PBDiagramImpl#getLocation <em>Location</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class PBDiagramImpl extends EObjectImpl implements PBDiagram {
	/**
	 * The cached value of the '{@link #getDelegate() <em>Delegate</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDelegate()
	 * @generated
	 * @ordered
	 */
	protected EObject delegate;

	/**
	 * The default value of the '{@link #isVisible() <em>Visible</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #isVisible()
	 * @generated
	 * @ordered
	 */
	protected static final boolean VISIBLE_EDEFAULT = false;

	/**
	 * The cached value of the '{@link #isVisible() <em>Visible</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #isVisible()
	 * @generated
	 * @ordered
	 */
	protected boolean visible = VISIBLE_EDEFAULT;

	/**
	 * The default value of the '{@link #getForegroundColor() <em>Foreground Color</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getForegroundColor()
	 * @generated
	 * @ordered
	 */
	protected static final RGB FOREGROUND_COLOR_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getForegroundColor() <em>Foreground Color</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getForegroundColor()
	 * @generated
	 * @ordered
	 */
	protected RGB foregroundColor = FOREGROUND_COLOR_EDEFAULT;

	/**
	 * The default value of the '{@link #getBackgroundColor() <em>Background Color</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getBackgroundColor()
	 * @generated
	 * @ordered
	 */
	protected static final RGB BACKGROUND_COLOR_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getBackgroundColor() <em>Background Color</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getBackgroundColor()
	 * @generated
	 * @ordered
	 */
	protected RGB backgroundColor = BACKGROUND_COLOR_EDEFAULT;

	/**
	 * The default value of the '{@link #getBorderColor() <em>Border Color</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getBorderColor()
	 * @generated
	 * @ordered
	 */
	protected static final RGB BORDER_COLOR_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getBorderColor() <em>Border Color</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getBorderColor()
	 * @generated
	 * @ordered
	 */
	protected RGB borderColor = BORDER_COLOR_EDEFAULT;

	/**
	 * The default value of the '{@link #getLineThickness() <em>Line Thickness</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getLineThickness()
	 * @generated
	 * @ordered
	 */
	protected static final int LINE_THICKNESS_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getLineThickness() <em>Line Thickness</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getLineThickness()
	 * @generated
	 * @ordered
	 */
	protected int lineThickness = LINE_THICKNESS_EDEFAULT;

	/**
	 * The default value of the '{@link #getSize() <em>Size</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getSize()
	 * @generated
	 * @ordered
	 */
	protected static final Dimension SIZE_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getSize() <em>Size</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getSize()
	 * @generated
	 * @ordered
	 */
	protected Dimension size = SIZE_EDEFAULT;

	/**
	 * The default value of the '{@link #getLocation() <em>Location</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getLocation()
	 * @generated
	 * @ordered
	 */
	protected static final Point LOCATION_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getLocation() <em>Location</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getLocation()
	 * @generated
	 * @ordered
	 */
	protected Point location = LOCATION_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected PBDiagramImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return PosterboardPackage.Literals.PB_DIAGRAM;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EObject getDelegate() {
		if (delegate != null && delegate.eIsProxy()) {
			InternalEObject oldDelegate = (InternalEObject)delegate;
			delegate = eResolveProxy(oldDelegate);
			if (delegate != oldDelegate) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, PosterboardPackage.PB_DIAGRAM__DELEGATE, oldDelegate, delegate));
			}
		}
		return delegate;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EObject basicGetDelegate() {
		return delegate;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setDelegate(EObject newDelegate) {
		EObject oldDelegate = delegate;
		delegate = newDelegate;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, PosterboardPackage.PB_DIAGRAM__DELEGATE, oldDelegate, delegate));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean isVisible() {
		return visible;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setVisible(boolean newVisible) {
		boolean oldVisible = visible;
		visible = newVisible;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, PosterboardPackage.PB_DIAGRAM__VISIBLE, oldVisible, visible));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public RGB getForegroundColor() {
		return foregroundColor;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setForegroundColor(RGB newForegroundColor) {
		RGB oldForegroundColor = foregroundColor;
		foregroundColor = newForegroundColor;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, PosterboardPackage.PB_DIAGRAM__FOREGROUND_COLOR, oldForegroundColor, foregroundColor));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public RGB getBackgroundColor() {
		return backgroundColor;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setBackgroundColor(RGB newBackgroundColor) {
		RGB oldBackgroundColor = backgroundColor;
		backgroundColor = newBackgroundColor;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, PosterboardPackage.PB_DIAGRAM__BACKGROUND_COLOR, oldBackgroundColor, backgroundColor));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public RGB getBorderColor() {
		return borderColor;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setBorderColor(RGB newBorderColor) {
		RGB oldBorderColor = borderColor;
		borderColor = newBorderColor;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, PosterboardPackage.PB_DIAGRAM__BORDER_COLOR, oldBorderColor, borderColor));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getLineThickness() {
		return lineThickness;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setLineThickness(int newLineThickness) {
		int oldLineThickness = lineThickness;
		lineThickness = newLineThickness;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, PosterboardPackage.PB_DIAGRAM__LINE_THICKNESS, oldLineThickness, lineThickness));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Dimension getSize() {
		return size;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setSize(Dimension newSize) {
		Dimension oldSize = size;
		size = newSize;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, PosterboardPackage.PB_DIAGRAM__SIZE, oldSize, size));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Point getLocation() {
		return location;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setLocation(Point newLocation) {
		Point oldLocation = location;
		location = newLocation;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, PosterboardPackage.PB_DIAGRAM__LOCATION, oldLocation, location));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case PosterboardPackage.PB_DIAGRAM__DELEGATE:
				if (resolve) return getDelegate();
				return basicGetDelegate();
			case PosterboardPackage.PB_DIAGRAM__VISIBLE:
				return isVisible() ? Boolean.TRUE : Boolean.FALSE;
			case PosterboardPackage.PB_DIAGRAM__FOREGROUND_COLOR:
				return getForegroundColor();
			case PosterboardPackage.PB_DIAGRAM__BACKGROUND_COLOR:
				return getBackgroundColor();
			case PosterboardPackage.PB_DIAGRAM__BORDER_COLOR:
				return getBorderColor();
			case PosterboardPackage.PB_DIAGRAM__LINE_THICKNESS:
				return new Integer(getLineThickness());
			case PosterboardPackage.PB_DIAGRAM__SIZE:
				return getSize();
			case PosterboardPackage.PB_DIAGRAM__LOCATION:
				return getLocation();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case PosterboardPackage.PB_DIAGRAM__DELEGATE:
				setDelegate((EObject)newValue);
				return;
			case PosterboardPackage.PB_DIAGRAM__VISIBLE:
				setVisible(((Boolean)newValue).booleanValue());
				return;
			case PosterboardPackage.PB_DIAGRAM__FOREGROUND_COLOR:
				setForegroundColor((RGB)newValue);
				return;
			case PosterboardPackage.PB_DIAGRAM__BACKGROUND_COLOR:
				setBackgroundColor((RGB)newValue);
				return;
			case PosterboardPackage.PB_DIAGRAM__BORDER_COLOR:
				setBorderColor((RGB)newValue);
				return;
			case PosterboardPackage.PB_DIAGRAM__LINE_THICKNESS:
				setLineThickness(((Integer)newValue).intValue());
				return;
			case PosterboardPackage.PB_DIAGRAM__SIZE:
				setSize((Dimension)newValue);
				return;
			case PosterboardPackage.PB_DIAGRAM__LOCATION:
				setLocation((Point)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case PosterboardPackage.PB_DIAGRAM__DELEGATE:
				setDelegate((EObject)null);
				return;
			case PosterboardPackage.PB_DIAGRAM__VISIBLE:
				setVisible(VISIBLE_EDEFAULT);
				return;
			case PosterboardPackage.PB_DIAGRAM__FOREGROUND_COLOR:
				setForegroundColor(FOREGROUND_COLOR_EDEFAULT);
				return;
			case PosterboardPackage.PB_DIAGRAM__BACKGROUND_COLOR:
				setBackgroundColor(BACKGROUND_COLOR_EDEFAULT);
				return;
			case PosterboardPackage.PB_DIAGRAM__BORDER_COLOR:
				setBorderColor(BORDER_COLOR_EDEFAULT);
				return;
			case PosterboardPackage.PB_DIAGRAM__LINE_THICKNESS:
				setLineThickness(LINE_THICKNESS_EDEFAULT);
				return;
			case PosterboardPackage.PB_DIAGRAM__SIZE:
				setSize(SIZE_EDEFAULT);
				return;
			case PosterboardPackage.PB_DIAGRAM__LOCATION:
				setLocation(LOCATION_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case PosterboardPackage.PB_DIAGRAM__DELEGATE:
				return delegate != null;
			case PosterboardPackage.PB_DIAGRAM__VISIBLE:
				return visible != VISIBLE_EDEFAULT;
			case PosterboardPackage.PB_DIAGRAM__FOREGROUND_COLOR:
				return FOREGROUND_COLOR_EDEFAULT == null ? foregroundColor != null : !FOREGROUND_COLOR_EDEFAULT.equals(foregroundColor);
			case PosterboardPackage.PB_DIAGRAM__BACKGROUND_COLOR:
				return BACKGROUND_COLOR_EDEFAULT == null ? backgroundColor != null : !BACKGROUND_COLOR_EDEFAULT.equals(backgroundColor);
			case PosterboardPackage.PB_DIAGRAM__BORDER_COLOR:
				return BORDER_COLOR_EDEFAULT == null ? borderColor != null : !BORDER_COLOR_EDEFAULT.equals(borderColor);
			case PosterboardPackage.PB_DIAGRAM__LINE_THICKNESS:
				return lineThickness != LINE_THICKNESS_EDEFAULT;
			case PosterboardPackage.PB_DIAGRAM__SIZE:
				return SIZE_EDEFAULT == null ? size != null : !SIZE_EDEFAULT.equals(size);
			case PosterboardPackage.PB_DIAGRAM__LOCATION:
				return LOCATION_EDEFAULT == null ? location != null : !LOCATION_EDEFAULT.equals(location);
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (visible: ");
		result.append(visible);
		result.append(", foregroundColor: ");
		result.append(foregroundColor);
		result.append(", backgroundColor: ");
		result.append(backgroundColor);
		result.append(", borderColor: ");
		result.append(borderColor);
		result.append(", lineThickness: ");
		result.append(lineThickness);
		result.append(", size: ");
		result.append(size);
		result.append(", location: ");
		result.append(location);
		result.append(')');
		return result.toString();
	}

} //PBDiagramImpl
